﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace Shuba.Web.cdc
{
    public partial class cdc_parameter : basePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        void BindData()
        {
            Shuba.Business.CDC bl = new Shuba.Business.CDC();
            List<string> col = bl.GetParameterTable();
            List<string> selected = bl.GetParameter();
            col.Sort();
            selected.Sort();

            lbListParam.DataSource = col;
            lbListParam.DataBind();

            lbSelectedParam.DataSource = selected;
            lbSelectedParam.DataBind();
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            List<string> list = new List<string>();
            foreach (ListItem item in lbSelectedParam.Items)
            {
                list.Add(item.Value);
            }
            Shuba.Business.CDC bl = new Shuba.Business.CDC();
            bl.SaveParameter(list);
        }

        protected void plus_Click(object sender, EventArgs e)
        {
            for (int i = lbListParam.Items.Count - 1; i >= 0; i--)
            {
                if (lbListParam.Items[i].Selected == true)
                {
                    lbSelectedParam.Items.Add(lbListParam.Items[i]);
                    ListItem li = lbListParam.Items[i];
                    lbListParam.Items.Remove(li);
                }
            }
        }

        protected void minus_Click(object sender, EventArgs e)
        {
            for (int i = lbSelectedParam.Items.Count - 1; i >= 0; i--)
            {
                if (lbSelectedParam.Items[i].Selected == true)
                {
                    lbListParam.Items.Add(lbSelectedParam.Items[i]);
                    ListItem li = lbSelectedParam.Items[i];
                    lbSelectedParam.Items.Remove(li);
                }
            }
        }
    }
}